package GUI;

import javax.swing.table.AbstractTableModel;

class TabelModelPuzzle extends AbstractTableModel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	// Two arrays used for the table data
	Object data[][] = { { 1, "2", "3" }, { "4", "5", "6" }, { "7", "8", " " } };
	String[] columnNames = { "", "", "" };

	@Override
	public int getRowCount() {
		return data.length;
	}

	@Override
	public int getColumnCount() {
		return columnNames.length;
	}
	public void setData(Object[][] data) {
		this.data = data;
	}
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return super.toString();
	}
	
	@Override
	public Object getValueAt(int row, int column) {
		return data[row][column];
	}

	@Override
	public void setValueAt(Object value, int row, int col) {
		if(value instanceof String)
			System.out.println("");
		if(value==null)
			data[row][col]=" ";
		else
			data[row][col] = value;
	}

	// Used by the JTable object to set the column names
	@Override
	public String getColumnName(int column) {
		return columnNames[column];
	}

	// Used by the JTable object to render different
	// functionality based on the data type
	
	@Override
	public boolean isCellEditable(int row, int column) {
		return true;
	}
}
